﻿#region

using System.Drawing;
using System.Windows.Forms;

#endregion

namespace Obsluga.Gui
{
    /// <summary>
    ///   A label that can be transparent.
    /// </summary>
    public class TransparentLabel : Control
    {
        /// <summary>
        ///   Creates a new <see cref = "TransparentLabel" /> instance.
        /// </summary>
        public TransparentLabel()
        {
            TabStop = false;
        }

        /// <summary>
        ///   Gets the creation parameters.
        /// </summary>
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;
                cp.ExStyle |= 0x20;
                return cp;
            }
        }

        /// <summary>
        ///   Paints the background.
        /// </summary>
        /// <param name = "e">E.</param>
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            // do nothing
        }

        /// <summary>
        ///   Paints the control.
        /// </summary>
        /// <param name = "e">E.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            using (SolidBrush brush = new SolidBrush(ForeColor))
            {
                e.Graphics.DrawString(Text, Font, brush, -1, 0);
            }
        }
    }
}